package demo01;

import java.util.ArrayList;
import java.util.List;

public class Composite extends Component {
   private  List<Component> children=new ArrayList<>();

    public Composite(String name) {
        super(name);
    }

    @Override
    public void Add(Component component) {
        children.add(component);

    }

    @Override
    public void Remove(Component component) {
children.remove(component);
    }

    @Override
    public void Display(int depth) {
        System.out.println(new String("-")+depth+name);
        for (Component c:children) {

            c.Display(depth+2);

        }
    }


}
